package day19.pack5;

import java.util.concurrent.*;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
        Callable<String> myThread = new MyThread();
        // 中间这个FutureTask对象用来接收返回值的
        FutureTask<String> task = new FutureTask<>(myThread);
        Thread thread = new Thread(task);
        thread.start();
        // 阻塞等待task线程结束的返回值
        try {
//            String res = task.get(10, TimeUnit.SECONDS);
            String res = task.get();
            System.out.println(res);
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (int i = 0; i < 100; i++) {
            System.out.println("main...");
        }


    }
}
